package com.zhaowt.controller;

import com.zhaowt.dto.R;
import com.zhaowt.dto.UserDto;
import com.zhaowt.pojo.SysUserInfo;
import com.zhaowt.service.SysUserInfoService;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * created by 赵文韬 on 2022/12/24 23:01
 */
@RestController()
@RequestMapping("usercontroller")
public class UserController {
    @Resource
    private SysUserInfoService sysUserInfoService;
    //注册写完
    @PostMapping("/regist")
    public R registry(@RequestBody UserDto userDto){
        SysUserInfo sysUserInfo = new SysUserInfo();
        BeanUtils.copyProperties(userDto, sysUserInfo);
        sysUserInfoService.addUser(sysUserInfo);
        return R.setOk();
    }
    //todo登录
    @PostMapping("login")
    public R login(@RequestBody UserDto userDto){
        sysUserInfoService.login(userDto);
        //todo
        return R.setOk();
    }

}
